package LeetCode;

public class LC_504_Base7 {

    public static void main(String[] args) {

    }

    public class Solution {
        public String convertToBase7(int num) {
            StringBuilder builder = new StringBuilder();
            if (num == 0) return 0 + "";
            int absNum = Math.abs(num);
            while (absNum != 0) {
                int result = absNum % 7;
                absNum = absNum / 7;
                builder.insert(0, result + "");
            }
            if (num < 0) builder.insert(0, "-");
            System.out.println("result : " + builder.toString());
            return builder.toString();
        }

    }

    static class Solution_2 {
        public static String convertToBase7(int num) {
            return Integer.toString(num, 7);
        }
    }
}